require File.dirname(__FILE__) + '/../../../lib/tasks/file_tasks'
require 'test/unit'
require 'mocha'
require 'rake'

class  WhenCallingCopyFilesTask < Test::Unit::TestCase

    def test_should_fail_when_calling_copyfiles_without_target_dir_parameter
        begin
            Rubicant::Tasks::CopyFiles.new('cf1')
            Rake.application['cf1'].invoke

            assert.fail('Should get RuntimeError requiring target')

        rescue RuntimeError => re
            assert_equal('Target directory must be defined (:target_dir)', re.message)
        end
    end

    def test_should_fail_when_calling_copyfiles_without_file_globs_parameter
        begin
            Rubicant::Tasks::CopyFiles.new('cf2') do |cf|
              cf.target_dir = "target_dir"
            end

            Rake.application['cf2'].invoke

            assert.fail('Should get RuntimeError requiring target')

        rescue RuntimeError => re
            assert_equal('Source files must be defined (:file_globs)', re.message)
        end
    end

    def test_should_fail_when_calling_copyfiles_without_base_dir_parameter
        begin
            Rubicant::Tasks::CopyFiles.new('cf3') do |cf|
              cf.target_dir = "target_dir"
              cf.file_globs = "**/*"
            end

            Rake.application['cf3'].invoke

            assert.fail('Should get RuntimeError requiring target')

        rescue RuntimeError => re
            assert_equal('Base directory must be defined (:base_dir)', re.message)
        end
    end


end